﻿using System;
using UnityEditor;
using UnityEngine;

//技能辅助
public class CastSkillAssist
{
    private Creature _owner;
    public void Init(Creature owner)
    {
        _owner = owner;
    }

    public Creature SelectEnemy()
    {
        //选中最近的可攻击的npc;
        float minDis = float.MaxValue;
        Creature minDisNpc = null;
       foreach(var npcPair in NpcMgr.GetInstance().AllNpc)
        {
            
            var npc = npcPair.Value;
            if (!npc.CanBeAttack(_owner)){ continue; }

            var dis = Util.Distance2_5D(npc.Position, _owner.Position);
            if (dis > GameSetting.MaxAutoSelectDis) { continue; }
            if (dis < minDis)
            {
                minDis = dis;
                minDisNpc = npc;
            }
            
        }
        return minDisNpc;
    }
}
